/**
 * 单元格内边距
 * @param {*} opt
 */
function scCellPaddingSetting(opt){
    var com = scCommon.instance();
    var crEle = com.crEle;

    opt = opt ? opt : {};

    var box = null;
    var listener = null;

    this.createView = function(option){
        option = option ? option : {};
        listener = option.listener;

        var padding = listener("getCellPadding");
        padding = padding ? padding : {};

        box = crEle(null, "sc-cellpadding-setting-detail");

        var list = [
            {label: "上边距", path: "padding", name: "top"},
            {label: "下边距", path: "padding", name: "bottom"},
            {label: "左边距", path: "padding", name: "left"},
            {label: "右边距", path: "padding", name: "right"}
        ];

        var numberOpt = {
            minNum: 0,
            maxNum: 10,
            unit: "厘米"
        }

        var row = null;
        var item = null;
        for(var i in list){
            item = list[i];

            if(i % 2 == 0){
                row = crEle(null, "sc-setting-row");
            }

            let label = crEle("label", "sc-setting-label");
            let number = new scNumber();
            
            numberOpt.name = item.name;
            numberOpt.value = padding[item.name];
            numberOpt.value = numberOpt.value != null ? numberOpt.value : 0;

            input = number.createView(numberOpt);
            label.innerText = item.label + "：";

            if(i % 2 == 0){
                input.style.marginRight = "30px";
            }

            row.appendChild(label);
            row.appendChild(input);
            box.appendChild(row);
        }

        return box;
    }

    this.getData = function(){
        return new Promise((resolve)=>{
            com.getData(box).then((d)=>{
                resolve({
                    padding: d
                });
            });
        });
    }
};